A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
This invention relates to compilers, and more particularly to an architecture for an extensible compiler.
As computer technology has advanced, computer programs have become correspondingly complex to the point where it is very difficult for a programmer to write an application program in the machine language of the computer. Thus, most programs are written in a high-level language that is easier for the programmer to work with and then converted by a compiler into the machine language of the computer.
The compiler is itself typically a computer program. Compilers can be very complicated to design and construct, often being too complicated for a single individual to design and construct in a timely manner. Teams of individuals working together typically must coordinate their efforts very well in order to have the different portions of the compiler each individual is working on operate together properly. Typically, compilers make it extremely difficult, if not impossible, for an individual not working closely with the team to contribute a portion of the compiler.
Additionally, compilers are typically designed and written for xe2x80x9cgeneralxe2x80x9d use. That is, rather than writing compilers targeted to specific tasks, industries or fields, a more general type of compiler is written. The result of such generalization is that some functionality (e.g., support for particular instructions) that would be beneficial in other specific tasks, industries or fields is not available in the compiler because such functionality is too specific. In rare cases, compilers are designed and written for specific tasks, industries, or fields. The result of such specialization is that some functionality that would be beneficial for other tasks, industries, or fields is not available in the compiler because such functionality is not needed for the specific task, industry, or field. Typically, neither sort of compiler allows additional functionality to be added, thereby, in the first case, causing additional complexity on the part of the high-level language programmer in order to carry out the desired functions, and in the second case, causing the compiler to fail to be used for the other functions.
The invention described below addresses these disadvantages, providing an extensible compiler architecture.
A compiler architecture is described herein that provides for easy extensibility. A question and answer methodology is used between a reduction engine and question handlers corresponding to nodes of a graph representing the program being compiled. By using the question and answer methodology, additional functionality can be added to the compiler by users, whether they are part of the original design team of the compiler or a subsequent user.
According to one aspect of the invention, each node in the graph is associated with one or more question handlers. In order to compile the program, the reduction engine dispatches a series of questions to the question handlers, each of which can ask one or more questions of other question handlers. Once all the questions have been answered, the reduction engine is left with a compiled program. All queries to other question handlers are performed via the reduction engine.
According to another aspect of the invention, the information that a question handler obtains is of a semantic rather than structural nature. Each node in the graph is only aware of the other nodes to which it has a direct link, not the entire topology or structure of the graph.
According to another aspect of the invention, a question handler can add new nodes and/or links to the graph, but cannot delete any node or link.
According to another aspect of the invention, by the user adding new nodes, new question handlers for at least some of those new nodes, and possibly new links, new functionality (e.g., instructions) can be supported by the compiler. A question handler corresponding to the new functionality includes the instructions necessary to create additional nodes, links or binary information in the graph, and/or ask questions of other nodes, to carry out the desired functionality.
According to another aspect of the invention, during the compilation process the reduction engine detects when a question was answered with potentially incorrect information. When such a situation is detected, the reduction engine xe2x80x9crolls backxe2x80x9d the compilation process, going back to a point where the incorrect information would have been given. The reduction engine then adds a rule that prevents that question from being answered until the appropriate subsequent time, and then proceeds to answer and dispatch other questions.